package com.example.springadvance.a01;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Service;

import java.time.Instant;

@Service
public class UserService implements ApplicationListener<ApplicationEvent> {
    @Override
    public void onApplicationEvent(ApplicationEvent event) {
        Object source = event.getSource();
        long timestamp = event.getTimestamp();
        System.out.println("事件源: " + source
                + "事件发布时间: " + Instant.ofEpochMilli(timestamp));
    }
}
